#include <linux/slab.h>
#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/pm.h>
#include <linux/input.h>
#include <linux/interrupt.h>
#include <linux/fsl_devices.h>
#include <linux/delay.h>
#include <linux/irq.h>

#include <mach/hardware.h>
#include <mach/lradc.h>
#include <mach/device.h>
#include <mach/regs-lradc.h>
// #include <../arch/arm/mach-mx28/mx28_pins.h>
#include <mach/pinctrl.h>
#include <linux/timer.h>

static struct class *glink_class;
static int tmout = 12;

static ssize_t timeout_show(struct device *dev, 
		struct device_attribute *attr, char *buf)
{
	// struct led_classdev *led_cdev = dev_get_drvdata(dev);

	/* no lock needed for this */
	// led_update_brightness(led_cdev);

	return sprintf(buf, "%u\n", tmout);
}

static ssize_t timeout_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t size)
{
	// struct led_classdev *led_cdev = dev_get_drvdata(dev);
	ssize_t ret = -EINVAL;
	char *after;
	unsigned long state = simple_strtoul(buf, &after, 10);
	size_t count = after - buf;

	// if (isspace(*after))
	// 	count++;

	// if (count == size) {
	// 	ret = count;

	// 	if (state == LED_OFF)
	// 		led_trigger_remove(led_cdev);
	// 	led_set_brightness(led_cdev, state);
	// }

	return ret;
}

static struct device_attribute glink_class_attrs[] = {
	__ATTR(timeout, 0644, timeout_show, timeout_store),
	// __ATTR(invert, 0644, invert_show, invert_store),

};
static int __devinit glink_class_init(void)
{
	printk("%s() %d\n", __FUNCTION__, __LINE__);
	glink_class = class_create(THIS_MODULE, "glink");
	if (IS_ERR(glink_class))
		return PTR_ERR(glink_class);
	printk("%s() %d\n", __FUNCTION__, __LINE__);
	glink_class->dev_attrs = glink_class_attrs;
	return 0;
}
static void __exit glink_class_exit(void)
{
	printk("%s() %d\n", __FUNCTION__, __LINE__);
	class_destroy(glink_class);
}
module_init(glink_class_init);
module_exit(glink_class_exit);

MODULE_AUTHOR("MenglongWoo@aliyun.com>");
MODULE_DESCRIPTION("glink-class");
MODULE_LICENSE("GPL");